/*
 *  levelUpGame - ViewController.h
 *  Copyright 2011 W. Reckman. All rights reserved.
 */
#ifndef VIEW_CONTROLLER_H
#define VIEW_CONTROLLER_H

#include <vector>
#include "ofxFboTexture.h"
#include "ofTrueTypeFont.h"
#include "ofImage.h"
#include "BackgroundView.h"
#include "GameView.h"

//NOTE: uncomment this to force viewport dimensions to 4x3 ratio
#define FORCE_VIEWPORT_4_TO_3

class GameModel;
class LevelUpApp;


class ViewController {
public:
	typedef std::vector<ofImage> vec_ofImage;
	typedef std::vector<std::vector<ofImage> > vec_vec_ofImage;
	
	struct VideoState {
		float minWin, maxWin;
		float backgroundSpeed, facadeSpeed;
	};
	
	explicit ViewController( const LevelUpApp& appRef_ );
	
	void setup();
	void update();
	void draw();
	
	const ofImage* getFeedbackImage( int playerId_, FEEDBACK_IMAGES fbType ) const;
	
	ofTrueTypeFont& getSmallFont() const;
	ofTrueTypeFont& getMediumFont() const;
	ofTrueTypeFont& getLargeFont() const;
	ofTrueTypeFont& getSmallPixelFont() const;
	ofTrueTypeFont& getLargePixelFont() const;
	int getCanvasWidth() const;
	int getCanvasHeight() const;
	const VideoState& getVideoState() const;
	const ofImage& getBalancePointerImage() const;
	const vec_ofImage& getTgtBalanceImages() const;
	
	void setViewportSize( int w, int h );
	
private:
	const Settings& s;
	const GameModel& game;
	bool renderToBeamer;
	int canvasWidth, canvasHeight;
	int viewportWidth, viewportHeight;
	
	mutable ofTrueTypeFont smallFont;
	mutable ofTrueTypeFont mediumFont;
	mutable ofTrueTypeFont largeFont;
	mutable ofTrueTypeFont smallPixelFont;
	mutable ofTrueTypeFont largePixelFont;
	
	float videoWindowSize;
	VideoState videoState;
	bool bgVideoFollowsBalance;
	bool bgVideoHasMirrorCopy;
	bool facadeVideoFollowsBalance;
	bool facadeVideoHasMirrorCopy;
	
	ofImage balancePointerImage;
	vec_ofImage tgtBalanceImages;
	vec_vec_ofImage feedbackImages;
	
	ofxFBOTexture fboTexture;
	BackgroundView bgView;
	GameView gameView;
	
	bool initFeedbackImages();
};

#endif /* ! VIEW_CONTROLLER_H */
